﻿using Business.Base;
using Business.Base.Enums;
using Pumptester.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Pumptester
{
    public partial class EntryForm : Form
    {
        public EntryForm()
        {
            InitializeComponent();
        }

        FormMoveAction action;

        ExperimentForms.Base.BaseMainForm experimentForm = null;

        private void EntryForm_Load(object sender, EventArgs e)
        {
            action = new FormMoveAction(this);
        }

        private void ucBtnNewExperiment_BtnClick(object sender, EventArgs e)
        {

           

        }

        private void ucBtnImg1_BtnClick(object sender, EventArgs e)
        {
            
        }



        private void button_MouseHover(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            button.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            button.FlatAppearance.BorderSize = 2;
        }

        private void button_MouseLeave(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            button.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            button.FlatAppearance.BorderSize = 1;
            
        }

        private void btnNew_Click(object sender, EventArgs e)
        {
            ChooseForm form = new ChooseForm(this);

            if (DialogResult.OK == form.ShowDialog())
            {
                if (form.ExperimentType == ExperimentType.CentrifugalPumpPerf)
                {
                    ExperimentForms.CentrifugalPump.Perf.CreateForm createForm = new ExperimentForms.CentrifugalPump.Perf.CreateForm();

                    if (createForm.ShowDialog() == DialogResult.OK)
                    {

                        ExperimentForms.CentrifugalPump.Perf.MainFormEnhance mainForm = new ExperimentForms.CentrifugalPump.Perf.MainFormEnhance(createForm.Experiment);
                        mainForm.EntryForm = this;
                        this.experimentForm = mainForm;

                        experimentForm.ShowDialog();
                        //experimentForm.FormClosed += ChildForm_FormClosed;
                    }
                    this.Show();

                }
                else if (form.ExperimentType == ExperimentType.ScrewPumpPerf)
                {
                    ExperimentForms.ScrewPump.Perf.CreateForm createForm = new ExperimentForms.ScrewPump.Perf.CreateForm();
                    if (createForm.ShowDialog() == DialogResult.OK)
                    {

                        ExperimentForms.ScrewPump.Perf.MainFormEnhance mainForm = new ExperimentForms.ScrewPump.Perf.MainFormEnhance(createForm.Experiment);
                        mainForm.EntryForm = this;


                        this.experimentForm = mainForm;
                        experimentForm.ShowDialog();
                    }
                    this.Show();

                }
                else if (form.ExperimentType == ExperimentType.NPSH)
                {
                    ExperimentForms.Npsh.CreateForm createForm = new ExperimentForms.Npsh.CreateForm();
                    if (createForm.ShowDialog() == DialogResult.OK)
                    {
                        ExperimentForms.Npsh.MainFormEnhance mainForm = new ExperimentForms.Npsh.MainFormEnhance(createForm.Experiment);
                        mainForm.EntryForm = this;

                        this.experimentForm = mainForm;
                        experimentForm.ShowDialog();
                    }
                    this.Show();
                }
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnHistroy_Click(object sender, EventArgs e)
        {
            ExperimentListForm form = new ExperimentListForm();
            this.Hide();
            form.ShowDialog();
            this.Show();
        }

        private void btnNew_TabIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
